package com.liuxu.topnews;

import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.widget.Toast;

import com.liuxu.topnews.bean.App;
import com.liuxu.topnews.utils.RootUtils;
import com.liuxu.topnews.utils.SettingUtils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import static com.liuxu.topnews.MyApplication.toast;


public class Read {
    private  AppInfo appinfo=new AppInfo();
    private int wrongtimes=4;
    public App app;
    public Map read_setting=new HashMap();

    public Read(){
        ArrayList<App> apps=new SettingUtils().GetDefaultXml();
        for (App app:apps){
            read_setting.put(app.getZname(),app);
        }
    }
    public void funnews(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException, NoSuchFieldException, IllegalAccessException {
        String appname=appinfo.funnews[0];
        String packname=appinfo.funnews[1];
        String acitvity=appinfo.funnews[2];
        showtoast(appname+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("领取"));
        Thread.sleep(2000);
        Helper.ClickNodes(Finder.findNodesByText("任务"));
        Thread.sleep(3000);
        Helper.ClickNodes(Finder.findNodesByText("头条"));
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Thread.sleep(1000);
            Finder.clickTextViewByText("评");
            if ( Finder.findNodesByText("我来说两句...").size()>0){
                Finder.clickTextViewByText("继续观看");
                wrong=wrongtimes;
                Helper.readslowbykey(app.getUptime(),app.getDowntime(),50,100,true);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void eastnews(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.eastnews[1];
        String acitvity=appinfo.eastnews[2];
        showtoast(appinfo.eastnews[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.swipe_down(2,200);
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Finder.clickTextViewByText("继续赚钱");
            Helper.swipe_up(2,200);
            Thread.sleep(1000);
            if (!Finder.clickTextViewByText("阅读")){
                if (!Finder.clickTextViewByText("分钟前")){
                    Finder.clickTextViewByText("次播放");
                }
            }
            Thread.sleep(1000);
            if (MyApplication.NowClassName.equals(MyApplication.newsname)){
                Finder.clickTextViewByText("继续播放");
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,true);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void newsmoremore(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.newsmoremore[1];
        String acitvity=appinfo.newsmoremore[2];
        showtoast(appinfo.newsmoremore[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("赚钱"));
        Thread.sleep(2000);
        Helper.ClickNodes(Finder.findNodesByText("首页"));
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Helper.Click(350,650);
            if ( Finder.findNodesById("com.lite.infoflow.browser:id/a5h").size()>0){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),3,1,app.getDowntime(),100,1250,true);
                time-=1;
            }else {
                wrong-=1;
                Helper.Click(100,1250);
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void youthnews(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.youthnews[1];
        String acitvity=appinfo.youthnews[2];
        
        showtoast(appinfo.youthnews[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Finder.clickTextViewByText("刷新");
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Thread.sleep(3000);
            Helper.swipe_up(3,200);
            Finder.clickTextViewByText("阅读");
            if ( Finder.findNodesByText("写评论...").size()>0){
                wrong=wrongtimes;
                Helper.readslowbykey(app.getUptime(),app.getDowntime(),50,100,true);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void weliseesee(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.weliseesee[1];
        String acitvity=appinfo.weliseesee[2];
        showtoast(appinfo.weliseesee[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Click(370,970);//收红包
        Helper.Back();
        Finder.clickTextViewByID("cn.weli.story:id/iv_gold_gif");
        Thread.sleep(1000);
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Thread.sleep(1000);
            Helper.Click(350,650);
            Thread.sleep(1000);
            if (MyApplication.NowClassName.equals(MyApplication.newsname)){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),2,0,app.getDowntime(),50,100,true);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void sohunews(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.sohunews[1];
        String acitvity=appinfo.sohunews[2];
        String allactivity = packname + "/" + acitvity;
        Log.v("搜狐咨询",allactivity);
        showtoast(appinfo.sohunews[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Finder.clickTextViewByText("首页");
        Finder.clickTextViewByText("刷新");
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            if (!Finder.clickTextViewByText("刚刚")){
                if (!Finder.clickTextViewByText("分钟前")){
                    Finder.clickTextViewByText("次播放");
                }
            }
            Thread.sleep(1000);
            if (MyApplication.NowClassName.equals(MyApplication.newsname)||MyApplication.NowClassName.equals("com.sohu.quicknews.articleModel.activity.VideoDetailActivity")){
                Finder.clickTextViewByText("继续播放");
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,true);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
        }
    public void bullnews(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.bullnews[1];
        String acitvity=appinfo.bullnews[2];
        showtoast(appinfo.bullnews[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("时段奖励"));
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("每日金币"));
        Thread.sleep(1000);
        Helper.ClickNodes(Finder.findNodesByText("资讯"));
        Helper.ClickNodes(Finder.findNodesByText("刷新"));
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Helper.Click(350,650);
            if ( Finder.findNodesByText("写评论...").size()>0){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,true);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void haicao(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.haicao[1];
        String acitvity=appinfo.haicao[2];
        
        showtoast(appinfo.haicao[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Thread.sleep(3000);
        Helper.Back();
        Finder.clickTextViewByText("领取");
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Finder.clickTextViewByID("com.billionstech.grassbook:id/iv_find_list_type_1");
            if ( Finder.findNodesByText("收藏").size()>0){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,true);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Back();
        Helper.Close(packname);
    }
    public void shandianhezi(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.shandianhezi[1];
        String acitvity=appinfo.shandianhezi[2];
        
        showtoast(appinfo.shandianhezi[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.Click(650,100);//右上角时段奖励
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("任务"));
        Thread.sleep(2000);
        Helper.ClickNodes(Finder.findNodesByText("立即签到"));
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("首页"));
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Helper.Click(350,650);
            if ( Finder.findNodesByText("c.l.a:id/weapp_title").size()>0){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Back();
        Helper.Close(packname);
    }

    public void mayinews(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.mayinews[1];
        String acitvity=appinfo.mayinews[2];
        
        showtoast(appinfo.mayinews[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.Click(50,1250);
        Thread.sleep(1000);
        Helper.Click(500,1250);
        Thread.sleep(2000);
        Helper.Click(550,280);
        Thread.sleep(2000);
        Helper.Back();
        Helper.Click(50,1250);
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Finder.clickTextViewByText("阅读");
            if ( Finder.findNodesByText("评论得金币...").size()>0){
                wrong=wrongtimes;
                Helper.swipe_up(3,200);
                Thread.sleep(2000);
                Finder.clickTextViewByDesc("open");
                Helper.readslowbytp(app.getUptime(),0,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void hbnews(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.hbnews[1];
        String acitvity=appinfo.hbnews[2];
        showtoast(appinfo.hbnews[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.swipe_up(2,200);
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Thread.sleep(1000);
            Helper.swipe_up(3,200);
            Helper.Click(350,650);
            if ( Finder.findNodesById("com.martian.hbnews:id/circularProgressBar").size()>0){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),3,0,app.getDowntime(),5,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void kankanzhuan(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.kankanzhuan[1];
        String acitvity=appinfo.kankanzhuan[2];
        showtoast(appinfo.kankanzhuan[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("领取"));
        Thread.sleep(1000);
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Thread.sleep(1000);
            Finder.clickTextViewByText("阅读");
            if ( Finder.findNodesByText("收藏").size()>0){
                wrong=wrongtimes;
                Helper.swipe_up(2,140);
                Finder.clickTextViewByText("查看全文");
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void qukantianxia(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.qukantianxia[1];
        String acitvity=appinfo.qukantianxia[2];
        
        showtoast(appinfo.qukantianxia[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("领取"));
        Thread.sleep(1000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("每日金币"));
        Thread.sleep(4000);
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Helper.Click(350,650);
            Thread.sleep(1000);
            if (MyApplication.NowClassName.equals(MyApplication.newsname)){
                wrong=wrongtimes;
                Helper.swipe_up(2,200);
                Finder.clickTextViewByDesc("展开查看全文");
                Helper.readslowbykey(app.getUptime(),app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void newsbus(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.newsbus[1];
        String acitvity=appinfo.newsbus[2];
        String newsity=appinfo.newsbus[3];
        showtoast(appinfo.newsbus[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.Click(100,90);
        Helper.Back();
        Helper.Click(100,1250);
        Thread.sleep(1000);
        Helper.Click(100,1250);
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.Click(100,1250);
            Thread.sleep(1000);
            Helper.Click(350,650);
            if ( Finder.findNodesById("com.zm.news:id/comment_fav_container").size()>0){
                wrong=wrongtimes;
                Helper.readslowbykey(app.getUptime(),app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void huashengnews(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.huashengnews[1];
        String acitvity=appinfo.huashengnews[2];
        
        showtoast(appinfo.huashengnews[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Helper.Click(50,1250);
            Helper.swipe_up(2,200);
            Thread.sleep(1000);
            Helper.Click(350,650);
            if ( Finder.findNodesByText("我来说两句...").size()>0){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),app.getDowntime(),0,15,50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Click(650,100);//右上角签到
        Helper.Close(packname);
    }
    public void mangguokandian(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.mangguokandian[1];
        String acitvity=appinfo.mangguokandian[2];
        
        showtoast(appinfo.mangguokandian[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("领取"));
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Helper.swipe_up(2,200);
            Thread.sleep(1000);
            Finder.clickTextViewByText("阅读");
            if ( Finder.findNodesById("com.kuaixun.mgkd:id/ll_comment").size()>0){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void songshu(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.songshu[1];
        String acitvity=appinfo.songshu[2];
        showtoast(appinfo.songshu[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Finder.clickTextViewByText("赚钱");
        Thread.sleep(2000);
        Helper.Click(370,380);
        Thread.sleep(1000);
        Finder.clickTextViewByText("首页");
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            if ( Finder.findNodesByText("推荐").size()>0){
                showtoast("阅读下一篇",false);
            }else {
                Finder.OpenAPP(packname);
                Thread.sleep(7000);
            }
            Helper.swipe_up(2,200);
            Thread.sleep(1000);
            Finder.clickTextViewByText("看过");
            if ( Finder.findNodesById("com.songshu.jucai:id/iv_favorite").size()>0){
                wrong=wrongtimes;
                Helper.swipe_up(1,200);
                Finder.clickTextViewByText("查看全文");
                Helper.readslowbytp(app.getUptime(),3,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void huitoutiao(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.huitoutiao[1];
        String acitvity=appinfo.huitoutiao[2];
        showtoast(appinfo.huitoutiao[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("时段奖励"));
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("任务中心"));
        Thread.sleep(1000);
        Helper.Click(100,1250);
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Helper.Click(350,650);
            if ( Finder.findNodesById("com.cashtoutiao:id/iv_hongbao").size()>0){
                Finder.clickTextViewByText("播放视频");
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void zhangshangnews(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.zhangshangnews[1];
        String acitvity=appinfo.zhangshangnews[2];
        showtoast(appinfo.zhangshangnews[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("任务"));
        Thread.sleep(1000);
        Helper.ClickNodes(Finder.findNodesByText("首页"));
        Thread.sleep(1000);
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Helper.ClickNodes(Finder.findNodesById("com.kdlc.hnmcc:id/tv_title"));
            if ( Finder.findNodesById("com.cashtoutiao:id/iv_hongbao").size()>0){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void zhongzishiping(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.zhongzishiping[1];
        String acitvity=appinfo.zhongzishiping[2];
        showtoast(appinfo.zhongzishiping[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("领取"));
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("赚钱"));
        Thread.sleep(1000);
        Helper.ClickNodes(Finder.findNodesByText("签到领金币"));
        Helper.Click(100,1250);
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Helper.Click(350,650);
            Thread.sleep(1000);
            if (MyApplication.NowClassName.equals(MyApplication.newsname)){
                Finder.clickTextViewByText("继续播放");
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void qukandian(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.qukandian[1];
        String acitvity=appinfo.qukandian[2];
        showtoast(appinfo.qukandian[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Click(100,1250);
        Helper.Back();
        Helper.swipe_up(1,200);
        Helper.ClickNodes(Finder.findNodesByText("可领取"));
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("任务"));
        Thread.sleep(1000);
        Helper.ClickNodes(Finder.findNodesByText("签到"));
        Thread.sleep(1000);
        Helper.Click(100,1250);
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Helper.swipe_up(2,200);
            Finder.clickTextViewByText("阅读");
            if ( Finder.findNodesById("com.zhangku.qukandian:id/collectIV").size()>0){
                wrong=wrongtimes;
                Helper.swipe_up(2,200);
                Finder.clickTextViewByID("com.zhangku.qukandian:id/header_information_read_all_btn");
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,true);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void yuequ(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.yuequ[1];
        String acitvity=appinfo.yuequ[2];
        showtoast(appinfo.yuequ[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.ClickNodes(Finder.findNodesByText("任务中心"));
        Thread.sleep(2000);
        Helper.Click(350,300);
        Thread.sleep(1000);
        Helper.Back();
        Helper.Click(100,1250);
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Helper.swipe_up(2,200);
            Helper.Click(350,650);
            if ( Finder.findNodesById("kulian.com.yuequ:id/rl_comment_collect_layout").size()>0){
                wrong=wrongtimes;
                Helper.readslowbytp(app.getUptime(),2,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void jukandian(RootUtils Helper, AccessService.Uiutil Finder) throws Exception {
        String packname=appinfo.jukandian[1];
        String acitvity=appinfo.jukandian[2];
        showtoast(appinfo.jukandian[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Thread.sleep(1000);
        Helper.ClickNodes(Finder.findNodesByText("任务中心"));
        Thread.sleep(3000);
        Helper.ClickNodes(Finder.findNodesByText("签到领金币"));
        Helper.Click(100,1250);
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Thread.sleep(4000);
            Helper.swipe_up(2,200);
            Thread.sleep(2000);
            Helper.ClickNodes(Finder.findNodesByText("阅读"));
            if ( Finder.findNodesByText("评论得金币").size()>0){
                wrong=wrongtimes;
                Helper.swipe_up(2,200);
                Thread.sleep(2000);
                Finder.clickTextViewByDesc("see");
                Helper.ClickNodes(Finder.findNodesByText("评论得金币"));
                Helper.ClickNodes(Finder.findNodesById("com.xiangzi.jukandian:id/dialog_comment_content"));
                Finder.set_text(Finder.findNodesById("com.xiangzi.jukandian:id/dialog_comment_content"),"好");
                Helper.ClickNodes(Finder.findNodesById("com.xiangzi.jukandian:id/dialog_comment_send"));
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void huishiping(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.huishiping[1];
        String acitvity=appinfo.huishiping[2];
        showtoast(appinfo.huishiping[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        Helper.Click(100,100);
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.OpenAPP(packname);
            Helper.Back();
            Thread.sleep(3000);
            Helper.swipe_up(3,200);
            Finder.clickTextViewByText("观看");
            if ( Finder.findNodesByText("收藏").size()>0){
                Finder.clickTextViewByText("继续播放");
                wrong=wrongtimes;
                Thread.sleep(40000);
                Finder.clickTextViewByID("com.cashvideo:id/iv_video_time_bg");
                Thread.sleep(2000);
                if (!MyApplication.NowClassName.equals(MyApplication.newsname)) {
                    Helper.Back();
                }
                Finder.clickTextViewByText("点击重播");
                Thread.sleep(40000);
                Finder.clickTextViewByID("com.cashvideo:id/iv_video_time_bg");
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void taozuiredian(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.taozuiredian[1];
        String acitvity=appinfo.taozuiredian[2];
        showtoast(appinfo.taozuiredian[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Helper.Back();
            Finder.OpenAPP(packname);
            Helper.swipe_up(2,200);
            Finder.clickTextViewByText("人看过");
            if ( Finder.findNodesByText("写点什么").size()>0){
                wrong=wrongtimes;
                Thread.sleep(3000);
                Helper.swipe_up(1,150);
                Finder.clickTextViewByDesc("查看全文");
                Helper.readslowbytp(app.getUptime(),2,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }
    public void taotoutiao(RootUtils Helper, AccessService.Uiutil Finder) throws InterruptedException, IOException {
        String packname=appinfo.taotoutiao[1];
        String acitvity=appinfo.taotoutiao[2];
        showtoast(appinfo.taotoutiao[0]+"开始运行",false);
        Finder.OpenAPP(packname);
        Thread.sleep(15000);
        Finder.clickTextViewByID("com.ly.taotoutiao:id/img_hd_close");
        Helper.Back();
        Finder.clickTextViewByText("领取");
        Finder.clickTextViewByText("任务");
        Thread.sleep(3000);
        Finder.clickTextViewByText("签到");
        Finder.clickTextViewByText("头条");
        Helper.Back();
        int time=app.getPagenumber();
        int wrong=wrongtimes;
        while(time>1&&wrong>1){
            Finder.clickTextViewByID("com.ly.taotoutiao:id/img_hd_close");
            Finder.OpenAPP(packname);
            Helper.Back();
            Helper.swipe_up(2,200);
            Finder.clickTextViewByText("来自");
            if ( Finder.findNodesById("com.ly.taotoutiao:id/btn_right").size()>0){
                wrong=wrongtimes;
                Thread.sleep(3000);
                Helper.swipe_up(2,200);
                Finder.clickTextViewByDesc("阅读全部内容");
                Helper.readslowbytp(app.getUptime(),1,0,app.getDowntime(),50,100,false);
                time-=1;
            }else {
                wrong-=1;
                Helper.Back();
            }
        }
        Helper.Close(packname);
    }

public void showtoast(final String text, final boolean now){
    Handler handlerThree=new Handler(
            Looper.getMainLooper());
    handlerThree.post(new Runnable(){
        public void run(){
            if (now) {
                toast.setText(text);
                toast.show();
            } else {
                Toast.makeText(MyApplication.getContext(),text,Toast.LENGTH_SHORT).show();
            }
        }
    });
}
}
